# __Author__ ='wenjxu'
# -*- coding: utf-8 -*-
# !/usr/bin/python3
# from httprunner import HttpRunner
import sys
# from AutoMateProject.conf.config import settings
# sys.path.append(settings.BASE_DIR)  # 添加项目环境变量
# kwargs = {'failfast': False, 'report_dir': 'E:\\demo\\test'}  # 看api.py中__init__方法参数
# runner = HttpRunner(**kwargs)
# result_runner = runner.run('E:\\autotest\\api_autotest\\testcases\\test_demo.yml')  # 执行指定目录下用例
# print(result_runner)  # 输出报告地址
# summary = runner.summary  # 获取执行结果，需要在run方法后
# print(summary)
# from requests.cookies import RequestsCookieJar
# import requests
# from AutoMateProject.utils.connection_redis import redis_conn
# print(redis_conn.get_conn().keys())
# redis_conn.get_conn().delete("T_oKhL855WsSNiz8T4UTWuniIb2o6E")
# url = "http://fanyi.baidu.com/v2transapi"
# cookie_jar = RequestsCookieJar()
# cookie_jar.set("BAIDUID", "B1CCDD4B4BC886BF99364C72C8AE1C01:FG=1", domain="baidu.com")
# res = requests.get(url, cookies=cookie_jar)
# print(res)

#
# from contextlib import closing
# class Query(object):
#     def __init__(self,name):
#         self.name = name
#     def query(self):
#         print('Query info about %s...' % self.name)
#
#     def close(self):
#         print("关闭了哦哦哦哦")
#
# with closing(Query('Bob')) as q:
#     q.query()
# import hashlib,time
# ctime = str(time.time())
# md5 = hashlib.md5()
# md5.update(bytes(ctime,'utf-8'))
# print(md5.hexdigest()[-8:])
#
# from importlib import import_module
# from AutoMateProject.conf.config import settings
# print(settings.PLUGINS_LIST)
#
# for plugin in settings.PLUGINS_LIST:
#     module_name,class_name = plugin.rsplit('.',1)
#
#     module = import_module(module_name)
#
#     obj = getattr(module,class_name)
#     print(obj)

# from  AutoMateProject.utils.connection_redis import redis_conn
# conn = redis_conn.get_conn()
# print(conn.set("sendmail",1))
# # conn.delete("sendmail")
# print(conn.keys())
# print(conn.get("sendmail"))



import optparse,time,threading,os
# parser = optparse.OptionParser()
# parser.add_option("-m", "--mail", dest="mail", help="add to mail")
# options, args = parser.parse_args()
# print(options.mail,type(args))
# if "openm" in args:
#     print("zai")
# for mailstaff in options.mail.split(","):
#     print(mailstaff)

name='a|b|c'
# print(name.rsplit('|',1)) #从右开始切分
def count():
    fs = []
    for i in range(1, 4):
        def f():
             return i*i
        fs.append(f)
    return fs

f1, f2, f3 = count()
# print(f1(),f2())
from datetime import datetime,timedelta

delta = datetime.strptime("2020-06-08","%Y-%m-%d") - datetime.strptime("2020-03-27","%Y-%m-%d")
# print(delta.days)
# print((datetime.strptime("2020-03-27","%Y-%m-%d") + timedelta(days=7)).strftime("%Y-%m-%d"))

def loop():
    print('thread %s is running...'%threading.current_thread().name)
    n = 0
    while n < 5:
        n = n + 1
        print('thread %s >>> %s'%(threading.current_thread().name,n))
        time.sleep(1)
    print('thread %s ended.'%threading.current_thread().name)
        
print('thread %s is running...'%threading.current_thread().name)
t = threading.Thread(target=loop,name='loopThread')
t.start()
t.join()
print('thread %s ended.'%threading.current_thread().name)

print(os.cpu_count())
































